<?php

	//银行返回数据/Bank Payment Result
	if(!isset($_POST)){
		$_POST = $_GET;
	}
	
	//Sha256加密支付返回数据:SHA256 encrypted payment result data 
	//数据组合/Data Combination: merNo + terNo + tradeNo + orderNo + orderCurrency + orderAmount +orderSucceed + signKey
	$signKey  = 'rB6t60l8Fkd';//密钥/Encryption Key
	$str      = $_POST['merNo'].$_POST['terNo'].$_POST['tradeNo'].$_POST['orderNo'].$_POST['orderCurrency'].$_POST['orderAmount'].$_POST['orderSucceed'].$signKey;
	$mySign   = strtoupper(hash('sha256',$str));	
	
	//判断支付结果/Determine The Payment Result
	if($mySign == $_POST['signInfo']) {
	    if($_POST['orderSucceed'] == '1'){
	    	//支付成功/Payment Success
	    	echo "Transaction successful !";
	    }else if($_POST['orderSucceed'] == '-1' || $_POST['orderSucceed'] == '-2'){
	    	//支付处理中/Payment Processing
	    	echo "Transaction processing !";
	    }else if($_POST['orderSucceed'] == '0'){
	    	//支付失败/Payment Failure
	    	echo "Transaction failure,the reason is :" . $_POST['orderResult'];
	    }else{
	    	//未知支付结果/Unknown Payment Result
	    	echo "Unknown result !";
	    }
	}else{
		//数据校验失败/Date Verification Failed
		echo "Data verification failed !";
	} 
	
	//异步通知/Notify Payment Result
	if('2' == $_POST['returnType']){
		die("OK");
	}
?>